package com.kaochong.xcx.dao.base;

import java.util.List;

/**
 * @author han
 * @date 2018-05-03 13:26
 */
public interface UserMistakesBaseMapper<T> {
	
	int deleteByPrimaryKey(Long id);
	
	int insert(T record);
	
	int insertSelective(T record);
	
	T selectByPrimaryKey(Long id);
	
	int updateByPrimaryKeySelective(T record);
	
	int updateByPrimaryKey(T record);
	
	/**
	 * 用户需要复习的错题
	 * @param userId
	 * @param targetMarkId
	 * @param status
	 * @param errorTimes
	 * @return
	 */
	List<T> findByUserIdAndTargetMarkIdAndStatusAndErrorTimes(Long userId, String
			targetMarkId, Integer status, Integer errorTimes);
	
	/**
	 * 查询用户前两阶段的错题
	 * @param userId
	 * @param targetMarkId
	 * @param status
	 * @param currStage
	 * @param errorTimes
	 * @return
	 */
	List<T> findByUserIdAndTargetMarkIdAndStatusAndStageLessThanAndErrorTimesLessThanEqual(Long
			                                                                                       userId, String
			targetMarkId, Integer status, Integer currStage, Integer errorTimes);
	
	/**
	 * 用户所有错题
	 * @param userId
	 * @param targetMarkId
	 * @return
	 */
	List<T> findByUserIdAndTargetMarkId(Long userId, String targetMarkId);
	
	/**
	 * 删除用户错题
	 * @param userId
	 * @param targetMarkId
	 * @return
	 */
	/*@Modifying
	@Query(value = "delete from bdc_user_mistakes_8 where user_id=?1 and target_mark_id=?2", nativeQuery = true)
	Integer deleteUserMistakes(Long userId, String targetMarkId);*/
	
	/**
	 * 删除用户错题
	 * @param userId
	 * @param targetMarkId
	 * @return
	 */
	Integer deleteByUserIdAndTargetMarkId(Long userId, String targetMarkId);
}
